<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>曲线滑动菜单指示器</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <header>
    <a href="#" class="logo">Logo</a>
    <nav>
      <div id="indicator"></div>
      <a href="#">Home</a>
      <a href="#">About</a>
      <a href="#">Protfolio</a>
      <a href="#">Team</a>
      <a href="#">Contact</a>
    </nav>
  </header>
</body>
<script>
  let indicator = document.querySelector('#indicator')
  let items = document.querySelectorAll('nav a')

  function marker(e) {
    indicator.style.left = e.offsetLeft + 'px'
    indicator.style.wdith = e.offsetWidth + 'px'
  }

  items.forEach(link => {
    link.addEventListener('click', e => {
      marker(e.target)
    })
  })
</script>

</html>